import React,{Component} from "react";
//跟vue v-model很像
export default class Form2 extends Component{

    state={
        username:'',
        password:''
    }
    showData1=(event)=>{
        this.setState({username: event.target.value});
    }
    showData2=(event)=>{
        this.setState({password: event.target.value});
    }
    onHandleForm=(event)=>{
        event.preventDefault();
        console.log(this.state.username,this.state.password);
    }

  render() {
   return(
       <form onSubmit={this.onHandleForm}>
           <input type={"text"} onChange={this.showData1}  placeholder={"账号"} name={"username"} />
           <input type={"text"}  onChange={this.showData2} placeholder={"密码"} name={"password"} />
           <button>提交</button>
       </form>
   )
  }
}
